package com.huashi.dealer.commonEntity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 上传文件实体类
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "上传文件实体")
@TableName("yoshop_upload_file")
public class UploadFile extends BaseModel {

    @TableId(value = "file_id", type = IdType.AUTO)
    @Schema(description = "文件ID")
    private Long fileId;

    @Schema(description = "存储方式")
    private String storage;

    @Schema(description = "文件分组ID")
    private Long groupId;

    @Schema(description = "存储域名")
    private String fileUrl;

    @Schema(description = "文件路径")
    private String fileName;

    @Schema(description = "别名")
    private String alias;

    @Schema(description = "文件大小(字节)")
    private Long fileSize;

    @Schema(description = "文件类型")
    private String fileType;

    @Schema(description = "文件扩展名")
    private String extension;

    @Schema(description = "是否为c端用户上传")
    private Integer isUser;

    @Schema(description = "是否已回收")
    private Integer isRecycle;

    /**
     * 是否删除
     */
    @TableField("is_delete")
    @Schema(description = "是否删除")
    @TableLogic
    private Integer isDelete;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Long createTime;

    @Schema(description = "创建时间")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTimeFormat;


    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
        this.setCreateTimeFormat(LocalDateTime.ofEpochSecond(createTime, 0, java.time.ZoneOffset.ofHours(8)));
    }
} 